﻿/*
 *  Copyright 2009 Duck Pond, Inc.
 *  http://www.duckpondinc.com/
 *  
 *  This file is part of Server Watch & Alert.
 *
 *  Server Watch & Alert is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  Server Watch & Alert is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Server Watch & Alert.  If not, see <http://www.gnu.org/licenses/>.
 *  
 * */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DuckPond.ServerWatchAlert.Core;

namespace DuckPond.ServerWatchAlert.Front.WinForms
{
    public partial class Monitor : Form
    {
        /////////////////////
        // CONSTRUCTORS
        /////////////
        public Monitor()
        {
            InitializeComponent();

            NotifyIcon_1.Icon = this.Icon;
            NotifyIcon_1.Text = this.Text;
            NotifyIcon_1.Visible = true;
        }


        /////////////////////
        // EVENT HANDLERS
        /////////////
        #region
        private void Monitor_Load(object sender, EventArgs e)
        {
            this.RadioButton_Disable.Checked = false;
            this.RadioButton_Enable.Checked = true;
        }

        private void Timer_MonitorTick_Tick(object sender, EventArgs e)
        {
            MonitorManager.Tick();
        }

        private void RadioButton_Enable_CheckedChanged(object sender, EventArgs e)
        {
            if (this.RadioButton_Enable.Checked)
            {
                this.Timer_MonitorTick.Start();
            }
        }

        private void RadioButton_Disable_CheckedChanged(object sender, EventArgs e)
        {
            if (this.RadioButton_Disable.Checked)
            {
                this.Timer_MonitorTick.Stop();
            }
        }

        private void NotifyIcon_1_MouseClick(object sender, MouseEventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                this.WindowState = FormWindowState.Normal;
            }

            this.ShowInTaskbar = true;
        }

        private void Monitor_Deactivate(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                this.ShowInTaskbar = false;
            }
        }
        #endregion
    }
}
